#!/bin/zsh
#function print_aarr() {
  emulate -L zsh; setopt local_options
  local MATCH MBEGIN MEND; local -a match mbegin mend  # appease 'warn_create_global'

  local input key val array_name
  local -A assoc_array

  # Read from standard input
  while IFS= read -r input; do
    if [[ $input =~ '^typeset -A ([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$' ]]; then
      array_name=${match[1]}
      printf '%-12s: %s\n' "\$assoc_arr" "${array_name}"
      eval "assoc_array=( ${match[2]} )"

      for key in ${(ok)assoc_array}; do
        val="$( print -r -- ${assoc_array[$key]} | subenv ANTIDOTE_HOME )"
        if [[ -z "$val" ]]; then
          printf '%-12s:\n' $key
        else
          printf '%-12s: %s\n' $key $val
        fi
      done
    else
      echo "Error: Input does not match an associative array declaration" >&2
      return 1
    fi
  done
#}
